package com.bwie.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.bwie.common.domain.Admin;
import com.bwie.common.result.Result;
import com.bwie.system.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

    @Autowired
    private UserService service;

    @Autowired
    private HttpServletRequest httpServletRequest;

    /**
     * 查询用户手机号
     * @param adminPhone
     * @return
     */
    @GetMapping("/findByAdminPhone")
    public Result<Admin> findByAdminPhone(@RequestParam String adminPhone){
        log.info("功能:查询用户手机号");
        log.info("请求方法:{}"+httpServletRequest.getMethod());
        log.info("请求路径:{}"+httpServletRequest.getRequestURL());
        log.info("请求参数:{}"+ JSONObject.toJSONString(adminPhone));
        Admin phone = service.findByAdminPhone(adminPhone);
        log.info("功能:查询用户手机号");
        log.info("请求方法:{}"+httpServletRequest.getMethod());
        log.info("请求路径:{}"+httpServletRequest.getRequestURL());
        log.info("响应结果:{}"+ JSONObject.toJSONString(phone));
        return Result.success(phone);
    }
}
